Skip to content

#209 - Add generic socket setsockopt API#211

Merged
cliffburdick merged 2 commits into
mainfrom
cburdick/socket-setsockopt-api
Jul 1, 2026
Merged

#209 - Add generic socket setsockopt API#211
cliffburdick merged 2 commits into
mainfrom
cburdick/socket-setsockopt-api

Conversation

@cliffburdick

@cliffburdick cliffburdick commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

For users wanting to customize the socket options for stream_type: socket, add an API to allow them to do so. Pass through the options to Linux.

Signed-off-by: Cliff Burdick <cburdick@nvidia.com>
@cliffburdick cliffburdick force-pushed the cburdick/socket-setsockopt-api branch from f46d041 to ac5d0be Compare July 1, 2026 19:55
@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds socket_setsockopt(conn_id, level, optname, optval, optlen) — a runtime passthrough to Linux setsockopt for TCP/UDP socket connections, deliberately skipping any YAML option-name mapping layer. The feature threads cleanly through the existing Engine vtable, with a NOT_SUPPORTED base-class default so non-socket engines require no changes.

  • C++ API (include/daqiri/common.h, src/common.cpp, src/engine.h/cpp): New public free-function dispatches via g_daqiri_engine->socket_setsockopt(); base class logs CRITICAL and returns NOT_SUPPORTED for engines that don't implement it.
  • Socket engine (src/engines/socket/daqiri_socket_engine.cpp): Full implementation with RoCE guard, null-optval check, shared_ptr connection lookup under state_mutex_, and ::setsockopt passthrough. A new private helper apply_socket_int_option consolidates the repeated int-valued setup calls (SO_REUSEADDR, TCP_NODELAY) that previously used bare ::setsockopt with silently ignored return values.
  • Python bindings (python/daqiri_common_pybind.cpp): Shim dispatches bool, int, str, bytes, and buffer-protocol objects; GIL is released before each C call and reacquired (via RAII) before any Python-heap cleanup, preserving correct destruction order.
  • Docs (AGENTS.md, README.md, all relevant docs/): Updated across every doc-sync target.

Confidence Score: 5/5

Safe to merge — the change is a clean vtable extension with no impact on non-socket engines and no modifications to the BurstParams or burst-free paths.

The new code touches only the socket engine and a new vtable slot. All doc-sync targets are updated, both commits carry DCO sign-offs, and the previous reviewer feedback has been incorporated. The Python shim handles GIL/lifetime ordering correctly across all value types, and the C++ implementation follows every established pattern in the socket engine for mutex-protected connection lookup.

No files require special attention.

Important Files Changed

Filename Overview
src/engines/socket/daqiri_socket_engine.cpp Implements socket_setsockopt with RoCE guard, null-optval validation, shared_ptr lookup under mutex, and ::setsockopt passthrough. Also introduces apply_socket_int_option helper that consolidates repeated int-valued setup calls.
python/daqiri_common_pybind.cpp Python shim correctly dispatches bool, int, str, bytes, and buffer-protocol objects, each releasing the GIL before the C call. Bool check precedes int check correctly; buffer path destruction order is safe.
include/daqiri/common.h Adds socket_setsockopt to the public free-function API; signature matches vtable and follows existing socket helper conventions.
src/engine.h Virtual method added to Engine base class; default implementation returns NOT_SUPPORTED, so non-socket engines degrade gracefully.
src/common.cpp Thin forwarding function follows established pattern: guards with ASSERT_DAQIRI_ENGINE_INITIALIZED(), dispatches through g_daqiri_engine vtable.
src/engine.cpp Default socket_setsockopt logs CRITICAL and returns NOT_SUPPORTED, matching the style of other unimplemented socket helpers.
src/engines/socket/daqiri_socket_engine.h Declares socket_setsockopt override and the private apply_socket_int_option helper; consistent with the implementation file.

Reviews (2): Last reviewed commit: "#209 - Address Greptile socket API feedb..." | Re-trigger Greptile

Comment thread include/daqiri/common.h
Comment thread python/daqiri_common_pybind.cpp
Signed-off-by: Cliff Burdick <cburdick@nvidia.com>
@cliffburdick cliffburdick merged commit d989d2b into main Jul 1, 2026
3 checks passed
@cliffburdick cliffburdick deleted the cburdick/socket-setsockopt-api branch July 1, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant